<template>
	<!-- //微信小程序 ：style="[]" 要用数组的形式 -->
	<view class="custom-page-defalut" >
		<view class="flex-column" style="justify-content: flex-start;">
			<block v-if="obj">
				 <view class="custom-form-item-textarea" v-for="(i,idx) in obj.fields" :key="idx">
				 	<view class="custom-form-label" >{{i.label}}:</view>
				 	<textarea  class="custom-form-textarea" :disabled="true" placeholder="无" :value="deepGet(obj.data,i.field)" ></textarea>
				 </view>
			</block>
		</view>
	       
    </view>
</template>

<script>
	export default{
		data(){
			return {
				obj:null
			}
		},
		onLoad({payload}) {
			if(payload){
				let _obj = JSON.parse(decodeURIComponent(payload));
				if(_obj)this.obj = _obj;
			}
		},
		methods:{
			deepGet(obj, keys, defaultVal) {
				return (
					(!Array.isArray(keys) ?
						keys.replace(/\[/g, '.').replace(/\]/g, '').split('.') :
						keys
					).reduce((o, k) => (o || {})[k], obj) || defaultVal
				);
			},
		}
	}
</script>

<style scoped>
		@import url('@/styles/layout/form.css');
</style>